<template>

	<view class="top">
		<view class="bar">
			<view class="tab-item" v-for="tab in tabs" :class="{active:tab.name === currentTab}"
				@click="switchTab(tab.name)">
				{{tab.title}}
			</view>
		</view>
		<slot :name="currentTab"></slot>
	</view>

</template>

<script>
	export default {
		name: "Tabs",
		data() {
			return {
				currentTab: 'music',
				// tab 数据
				tabs: [{
					name: 'my',
					title: '我的'
				}, {
					name: 'music',
					title: '音乐馆'
				}, {
					name: 'discover',
					title: '发现'
				}]
			}
		},
		methods: {
			switchTab(tabName) {
				this.currentTab = tabName;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.top {
		width: 100%;
		box-sizing: border-box;
		font-size: 32rpx;

		.bar {
			display: flex;
			justify-content: center;
			line-height: 100rpx;
			background-color: #00c273;
			color: #fff;
			height: 10vh;


			.tab-item {
				margin: 0 10rpx;
			}

			.active {
				color: black;
				font-size: 40rpx;
				font-weight: bold;
			}
		}
	}
</style>